package com.pucong.gitee.database.backup.business.unRelational.redis.util;

import com.pucong.gitee.database.backup.common.entity.redis.RedisConnect;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;

import java.util.HashMap;
import java.util.Map;

public class RedisDataUtil {

    private static Map<String, RedisConnect> redisConnectMap = new HashMap<>();

    public RedisDataUtil() {
    }

    public static void clearConfig(String userId, String redisId) {
        redisConnectMap.remove(getKey(userId, redisId, "connect"));
    }

    public static RedisConnect getRedisConnect(String userId, String redisId) {
        return redisConnectMap.get(getKey(userId, redisId, "connect"));
    }

    public static void setRedisConnect(String userId, String redisId, RedisConnect redisConnect) {
        redisConnectMap.put(getKey(userId, redisId, "connect"), redisConnect);
    }

    private static String getKey(String userId, String redisId, String key) {
        return userId + redisId + key;
    }
}
